package cn.itsource.service.user.imp;

import cn.itsource.mapper.user.UserMapper;
import cn.itsource.service.user.IUserService;
import cn.itsource.user.domain.User;
import cn.itsource.user.query.UserQuery;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserService implements IUserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public List<User> selectAll() {
        return userMapper.selectALL();
    }

    @Override
    public void deleteOne(Integer id) {
        userMapper.deleteOne(id);
    }

    @Override
    public void update(User user) {
        userMapper.update(user);
    }

    @Override
    public void add(User user) {
        userMapper.add(user);
    }

    @Override
    public PageInfo<User> queryUser(UserQuery userQuery) {
        // 设置分页参数
        PageHelper.startPage(userQuery.getCurrentPage(),userQuery.getPageSize());
        List<User> users = userMapper.queryUser(userQuery);

        return new PageInfo<>(users);
    }

    @Override
    public void deleteMore(Long[] id) {
        userMapper.deleteMore(id);
    }

}
